var api = require('../../utils/api.js');

var app = getApp();

Page({

    /**
     * 页面的初始数据
     */
    data: {
        descwin:0,
        address:'',
        info:'',
        list:'',
        shows:0,
        counts:[],
        mores:[]
    },

    setshow(ret){
        console.log(ret)
        var show=ret.currentTarget.dataset.i;
        this.setData({
            shows:show
        })

        this.getcasedata();
        this.getcases();
     
    },

    onLoad(ret){
        var that=this;

        that.setData({
            id:ret.id
        })

    },


    getcases(){
        var that=this;
        var id=this.data.id;

        api.post({
            url: 'cases/getcasebyid',
            data: {id:id},
            success: data => {
                that.setData({
                    info:data.data
                })
            }
        })
    },



    getcasedata(){
      
        var that=this;
        var id=this.data.id;

        api.post({
            url: 'cases/getcasedata',
            data: {id:id},
            success: data => {
                that.setData({
                    counts:data.data
                })
            }
        })

    },
    setshowhide(){
        this.setData({
            show:0
        })
    },
    seeinfo(ret){
        var type=ret.currentTarget.dataset.i;
        wx.navigateTo({
            url:'/pages/about/update?code='+type
        })
    },

    onShow(){
        
        var user=wx.getStorageSync('user');

        this.setData({
            uid:user.id
        })

        this.getcasedata();
        this.getcases();
        this.getmorelist();
    },

    getmorelist(){
        var that=this;
        var id=this.data.id;
        api.post({
            url: 'cases/getmorelist',
            data: {id:id},
            success: data => {
                that.setData({
                    mores:data.data
                })
            }
        })
    },

    getstatus(ret){
        console.log(ret);
        var type=ret.currentTarget.dataset.i;
        var id=this.data.id;
        var that=this;

        api.post({
            url: 'cases/getlistbytype',
            data: {type:type,id:id},
            success: data => {
                that.setData({
                    list:data.data,
                    show:1
                })
            }
        })

    },

    getstatusno(ret){
        console.log(ret);
        var type=ret.currentTarget.dataset.i;
        var id=this.data.id;
        var that=this;

        api.post({
            url: 'wxapp/Caseinfo/getlistbytypeno',
            data: {type:type,id:id},
            success: data => {
                that.setData({
                    list:data.data,
                    show:1
                })
            }
        })

    },
    getstatusyes(ret){
        console.log(ret);
        var type=ret.currentTarget.dataset.i;
        var id=this.data.id;
        var that=this;
        var shows=this.data.shows;


        api.post({
            url: 'wxapp/Caseinfo/getlistbytypeyes',
            data: {type:type,id:id,shows:shows},
            success: data => {
                that.setData({
                    list:data.data,
                    show:1
                })
            }
        })

    },

    seelive(){
        var id=this.data.id;
        wx.navigateTo({
          url: '/pages/live/index?id='+id,
        })
    },
    
    nexturl(){
        var id=this.data.id;
        wx.navigateTo({
          url: '/pages/list/xiangmu?id='+id,
        })
    },

    seeinfolist(){

        var id=this.data.id;
        wx.navigateTo({
          url: '/pages/list/goods?id='+id,
        })
    },

    seeinfos(){
        var id=this.data.id;
        wx.navigateTo({
          url: '/pages/project/info?id='+id,
        })
    },

    baoxiao(){
        var id=this.data.id;
        wx.navigateTo({
          url: '/pages/project/clearing?id='+id,
        })
    },

    ordersuccess(){
        var that=this;
        var id=this.data.id;
        wx.showModal({
          title: '确认完成',
          content: '确认订单已经完成？',
          complete: (res) => {
          
            if (res.confirm) {
                api.post({
                    url: 'cases/setordersuccess',
                    data: {id:id},
                    success: data => {
                        wx.showToast({
                          title: '操作成功',
                          icon:'none'
                        })
                    }
                })
            }
          }
        })

    },

    seenosetlist(ret){
        console.log(ret);
        var index=ret.currentTarget.dataset.i;
        var type=ret.currentTarget.dataset.t;
        var mores=this.data.mores;

        var list=mores[index].list1;

        this.setData({
            show:1,
            list:list
        })
    },

    
    seenosetlist0(ret){
        console.log(ret);
        var index=ret.currentTarget.dataset.i;
        var type=ret.currentTarget.dataset.t;
        var mores=this.data.mores;

        var list=mores[index].list1;

        this.setData({
            show:1,
            list:list
        })
    },
    seenosetlist1(ret){
        console.log(ret);
        var index=ret.currentTarget.dataset.i;
        var type=ret.currentTarget.dataset.t;
        var mores=this.data.mores;

        var list=mores[index].list2;

        this.setData({
            show:1,
            list:list
        })
    },

    seetit(ret){
        var index=ret.currentTarget.dataset.t;
        var mores=this.data.mores;

        this.setData({
            descwin:1,
            showdesc:mores[index].desc,
            showimgs:mores[index].setimg,
            showicons:mores[index].icons

        })
  

    },
    closedesc(){
        this.setData({
            descwin:0
        })

    },
    seeimages(){
        var imgs=this.data.showimgs;

        wx.previewImage({
            current: imgs[0], // 当前显示图片的http链接
            urls: imgs // 需要预览的图片http链接列表
        });

    }
})